package day14;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Scanner;

public class FileDemo {
	public static void main(String[] args) {
		System.out.println("请输入文件名：");
		Scanner scanner = new Scanner(System.in);
		String pathName = scanner.next();
		File file = new File(pathName);
		if(!file.exists()){
			try {
				file.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		System.out.println("文件是否存在：" + file.exists());
		System.out.println("是文件吗：" + file.isFile());
		System.out.println("是目录吗:" + file.isDirectory());
		System.out.println("名称:" + file.getName());
		System.out.println("路径：" + file.getPath());
		System.out.println("绝对路径：" + file.getAbsolutePath());
		System.out.println("最后修改时间：" + new Date(file.lastModified()).toString()	);
		System.out.println("文件大小：" + file.length());
	}
}
